package com.zzyl.nursing.service.impl;

import java.util.List;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.NursingProjectPlanMapper;
import com.zzyl.nursing.domain.NursingProjectPlan;
import com.zzyl.nursing.service.INursingProjectPlanService;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;

/**
 * 护理计划和项目关联Service业务层处理
 * 
 * @Author: Zhy
 * @Date: 2025-02-24
 */
@Service
@RequiredArgsConstructor
public class NursingProjectPlanServiceImpl extends ServiceImpl<NursingProjectPlanMapper, NursingProjectPlan> implements INursingProjectPlanService {

    private final NursingProjectPlanMapper nursingProjectPlanMapper;

    /**
     * 查询护理计划和项目关联
     * 
     * @param: id 护理计划和项目关联主键
     * @return: 护理计划和项目关联
     */
    @Override
    public NursingProjectPlan selectNursingProjectPlanById(Integer id) {
                return getById(id);
    }

    /**
     * 查询护理计划和项目关联列表
     * 
     * @param: nursingProjectPlan 护理计划和项目关联
     * @return: 护理计划和项目关联
     */
    @Override
    public List<NursingProjectPlan> selectNursingProjectPlanList(NursingProjectPlan nursingProjectPlan) {
        return nursingProjectPlanMapper.selectNursingProjectPlanList(nursingProjectPlan);
    }

    /**
     * 新增护理计划和项目关联
     * 
     * @param: nursingProjectPlan 护理计划和项目关联
     * @return: 结果
     */
    @Override
    public int insertNursingProjectPlan(NursingProjectPlan nursingProjectPlan) {

                return save(nursingProjectPlan) ? 1 : 0;
    }

    /**
     * 修改护理计划和项目关联
     * 
     * @param: nursingProjectPlan 护理计划和项目关联
     * @return: 结果
     */
    @Override
    public int updateNursingProjectPlan(NursingProjectPlan nursingProjectPlan) {

                return updateById(nursingProjectPlan) ? 1 : 0;
    }

    /**
     * 批量删除护理计划和项目关联
     * 
     * @param: ids 需要删除的护理计划和项目关联主键
     * @return: 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteNursingProjectPlanByIds(Integer[] ids) {
                return removeBatchByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除护理计划和项目关联信息
     * 
     * @param: id 护理计划和项目关联主键
     * @return: 结果
     */
    @Override
    public int deleteNursingProjectPlanById(Integer id) {
                return removeById(id) ? 1 : 0;
    }

}
